/*
 * 작성일 : 2014. 10. 30.
 * 작성자 : hch1982
 *
 * 설명
*/ 
/**
 * 
 */
package springbook.user;

import java.sql.SQLException;

import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import springbook.user.dao.DaoFactory;
import springbook.user.dao.UserDao;
import springbook.user.domain.User;

/**
 * @author hch1982
 *
 * 코드 수정 히스토리
 * 날짜		작업자		태그
 * 2014. 10. 30.	hch1982	
 */
public class UserDaoTest {
	/*
	 * 제어의 역전
	 * 팩토리
	 */
	public static void main(String[] args) throws ClassNotFoundException, SQLException{
		//UserDao dao = new UserDao(new DConnectionMaker());
		//UserDao dao = new DaoFactory().userDao();
		
		ApplicationContext context = new AnnotationConfigApplicationContext(DaoFactory.class);
		
		UserDao dao = context.getBean("userDao", UserDao.class);
		
		User user = new User();
		user.setId("whiteship");
		user.setName("백기선");
		user.setPassword("married");
		
		dao.add(user);
		
		System.out.println(user.getId() + "등록 성공");
		
		User user2 = dao.get(user.getId());
		System.out.println(user2.getName());
		
		System.out.println(user2.getPassword());
		
		System.out.println(user2.getId() + "조회 성공");
		
	}
}
